package com.andnnl.map;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by chenss on 2021/1/5.
 */
public class ListDiffTest {

    static void testArgs(String... args){
        System.out.println(args);
    }

    @SafeVarargs
    static  <T> void  testArgs2(T... args){
        T[] a=args;
        System.out.println(args);
        System.out.println(a);
    }

    public static void main(String[] args) {
        testArgs2("1","2","3");
        testArgs2(new String[]{"4","5","6"});

        testArgs2(1,2,3);
        testArgs2(new int[]{4,5,6});
        testArgs2(new Integer[]{new Integer(1),new Integer(1),new Integer(1)});

        int[] arr = {1,2,3};
        List listaa = Arrays.asList(arr) ;
        System.out.println( listaa.size() );


        Map<String, List<Integer>> bigMap = new HashMap<>();
        bigMap.put("科室1", Arrays.asList(1, 2, 3, 4));
        bigMap.put("科室2", Arrays.asList(1, 2, 3, 4));
        Map<String, List<Integer>> smallMap = new HashMap<>();
        smallMap.put("科室1", Arrays.asList(1, 2));




        Map<String, List<Integer>> map3=Stream.of(bigMap,smallMap)
                .flatMap(map -> map.entrySet().stream())
                .collect(Collectors.toMap(
                        Map.Entry::getKey,
                        Map.Entry::getValue,
                        (v1, v2) -> v1.stream().filter(item -> !v2.contains(item)).collect(Collectors.toList())));

        System.out.println(bigMap);
        System.out.println(smallMap);
        System.out.println(map3);


//        Map<String, List<Integer>>
        for (Map.Entry<String, List<Integer>> entry : smallMap.entrySet()) {
            String k=entry.getKey();
            List<Integer> v = entry.getValue();
            List<Integer> list=bigMap.get(k);
            if(list!=null) {
                list.removeAll(v);//Arrays.asList不可变 Exception in thread "main" java.lang.UnsupportedOperationException
            }

        }

        System.out.println(bigMap);


    }
}
